<template>
	<view class="common-box" @click="handleGo">
		<view class="start-box">
			<view class="start-title">
				<image src="/static/icon/logo.svg" mode=""></image>
				<text>TIES</text>
			</view>
		</view> 
	</view>
</template>

<script setup>
import { onMounted } from 'vue';
import TokenManager from '@/utils/token.js';

const handleGo = () => {
	if (!uni.getStorageSync('tradevase-firstVisit')) {
			uni.setStorageSync('tradevase-firstVisit', true);

			uni.navigateTo({
				url: "/pages/start/start2"
			})
		} else {
			// 使用TokenManager检查refreshToken
			const refreshToken = TokenManager.getRefreshToken();
			console.log('🔍 检查refreshToken:', refreshToken);
			
			if (refreshToken) {
				console.log('✅ 有token，跳转到home页面');
				uni.switchTab({
					url: "/pages/home/home"
				})
			} else {
				console.log('❌ 无token，跳转到登录页面');
				uni.navigateTo({
					url: '/pages/start/start3'
				})
			}
		}
}

onMounted(() => {
	console.log('🚀 start页面onMounted执行');
	setTimeout(() => {
		handleGo()
	}, 3000)
})
</script>

<style lang="scss" scoped>
	.start-box {
		display: flex;
		flex-direction: column;
		justify-content: center;
		height: 100vh;
		.start-title {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			margin-bottom: 59rpx;

			image {
				width: 139.53rpx;
				height: 99.02rpx;
				margin-bottom: 20rpx;
			}
			text {
				background-image: linear-gradient(90deg, rgba(11, 187, 160, 1) 0%, rgba(8, 166, 179, 1) 50%, rgba(2, 121, 219, 1) 100%);
				/** 文本1 */
				font-size: 62.79rpx;
				font-weight: 700;
			    -webkit-background-clip: text; /* 裁剪背景到文字 */
			    color: transparent; /* 文字颜色设置为透明，以便显示背景颜色 */
			}
		}

	}
</style>